<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<?php

try{
    $pdo = new PDO("mysql:dbname=test01;host=127.0.0.1","root","");
    $pdo->exec("SET NAMES 'utf8';");
    $new_sql = "SELECT s.`name`,s.`sex`,c.`text` FROM `tb_stu` s INNER JOIN `tb_comment` c ON s.`user_id` = c.`user_id`;";
    $res = $pdo->query($new_sql);

    echo "<table border='1'>";
    foreach ($res as $v){
        echo "<tr>";
        echo "<td> {$v['name']}</td>";
        echo "<td> {$v['sex']}</td>";
        echo "<td> {$v['text']}</td>";
        echo "</tr>";
    }
    echo "</table>";
}catch (Exception $e){
    echo "失败".$e->getMessage();
}